package org.dc.utlity;

import android.view.View;
import android.widget.Spinner;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;

/**
 * @user: Vladimir Chernishov
 * @date: 2/28/12
 * @time: 10:28 PM
 */
public class UIUtility {

    public static void updateTableWidth(TableLayout table, int pixels) {
        int rows = table.getChildCount();
        for (int i =0; i < rows; i++ ) {
            TableRow row = (TableRow)table.getChildAt(i);
            int columns = row.getChildCount();
            for(int ii = 0; ii < columns; ii++){
                View child = row.getChildAt(ii);
                int width = pixels / columns;
                if(child instanceof TextView){
                    ((TextView) child).setWidth(width);
                } else {
                    child.getLayoutParams().width = width;
                }

            }
        }
    }

}
